//
//  TLAVPlayer.h
//  TLAVPlayerDemo
//
//  Created by Tianlong on 2017/6/30.
//  Copyright © 2017年 Tianlong. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import "TLCoverView.h"
#import "TLAVPlayerPublicFile.h"

@class TLAVPlayer;
@protocol TLPlayerDelegate <NSObject>
/**
 自给播放器设置URL后：会频繁调用该代理方法，时时反馈播放器当前的状态
 */
@optional
-(void)player:(TLAVPlayer *)player playerStateDidChanged:(TLPlayerState)state;
@end


@interface TLAVPlayer : UIView

/**
 player
 */
@property (nonatomic , strong) AVPlayer *player;

/**
 playerLayer
 */
@property (nonatomic , strong) AVPlayerLayer *playerLayer;

/**
 承载playerLayer的view
 */
@property (nonatomic, weak) UIView *playerLayerView;

/**
 播放器当前的状态
 */
@property (nonatomic , assign) TLPlayerState state;

/**
 重新读取URL：适用于详情页面YES：在设置url会重新读取url对应的视频内容，NO：相同的URL不会重复读取
 */
@property (nonatomic , assign) BOOL resetVideoURL;

/**
 视频播放地址
 */
@property (nonatomic , copy) NSString *videoUrl;

/**
 全屏半屏
 */
@property (nonatomic , assign) BOOL isFullScreen;

/**
 视频封面
 */
@property (nonatomic , copy) NSString *coverURL;

/**
 开始播放时间点
 */
@property (nonatomic , assign) double beginTime;

/**
 结束播放时间点
 */
@property (nonatomic , assign) double endTime;

/**
 是否是自动播放
 */
@property (nonatomic , assign) BOOL autoPlay;

/**
 半屏时是否显示返回键:YES：半屏的时候也显示返回键 NO：半屏的时候不显示返回键。无论设置与否全屏都显示返回键
 */
@property (nonatomic , assign) BOOL showBackBtnInSmallScreen;

/**
 播放完成的回调
 */
@property (nonatomic , copy) void (^playFinished)();

/**
 点击返回键
 */
@property (nonatomic , copy) void (^clickedBackBtnBlock)();

/**
 全屏，半屏 block
 */
@property (nonatomic , copy) void (^clickdeScreenBlock)(BOOL isFullScreen);

/**
 TLAVPlayerPrepareViewDelegate
 */
@property (nonatomic , weak) id<TLPlayerDelegate> delegate;

/**
 封面图
 */
@property (nonatomic , weak) TLCoverView *coverView;

/***************** Function*************** Function******************** Function******* */
/**
 手动播放调用该方法
 */
-(void)resume;


/**
 暂停时继续播放用该方法
 */
-(void)play;

/**
 暂停播放
 */
-(void)pause;

/**
 销毁
 */
-(void)destroy;

/**
 停止加载：暂停视频的播放，取消playerItem的加载
 */
-(void)stop;

@end
